package com.tjetc.service.impl;

import com.tjetc.entity.FriendLinks;
import com.tjetc.entity.ShoePhotos;
import com.tjetc.dao.ShoePhotosDao;
import com.tjetc.entity.Shoes;
import com.tjetc.service.ShoePhotosService;
import com.tjetc.util.Pager;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * 鞋图片表(ShoePhotos)表服务实现类
 *
 * @author makejava
 * @since 2025-09-13 16:06:07
 */
@Service("shoePhotosService")
public class ShoePhotosServiceImpl implements ShoePhotosService {
    @Resource
    private ShoePhotosDao shoePhotosDao;


    @Override
    public Object queryByPage(String name, Integer pageNum, Integer pageSize) {
        //查询总记录数
        Integer recordCount = shoePhotosDao.count(name);
        System.out.println("--------------"+recordCount);
        //构建分页信息对象
        Pager pager = new Pager(pageNum, pageSize, recordCount);
        //根据pager查询需要的数据
        List<ShoePhotos> list = shoePhotosDao.query(name,pager.getStart(), pageSize);
        //将分页信息和查询到的数据一起返回到前端
        HashMap<String,Object> map = new HashMap<>();
        map.put("pager",pager);
        map.put("list",list);
        return map;
    }

    @Override
    public void insert(ShoePhotos shoePhotos) {
        this.shoePhotosDao.insert(shoePhotos);
    }

    @Override
    public void deleteById(Long id) {
        this.shoePhotosDao.deleteById(id);
    }
}
